package com.qjdchina.sku.converter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.qjdchina.sku.model.Brand;
import com.qjdchina.sku.model.vo.BrandVO;

public class BrandConverter {

	
	private BrandConverter(){
		
	}
	/**
	 * Brand to BrandVO
	 * @param brand
	 * @return
	 */
	public static BrandVO toBrandVO(Brand brand){
		
		BrandVO brandVO=new BrandVO();
		if (null==brand) {
			return brandVO;
		}
		BeanUtils.copyProperties(brand, brandVO);
		return brandVO;
	}
	/**
	 * BrandVO to Brand
	 * @param brandVO
	 * @return
	 */
	public static Brand toBrand(BrandVO brandVO){
		
		Brand brand=new Brand();
		if (null==brandVO) {
			return brand;
		}
		BeanUtils.copyProperties(brandVO, brand);
		return brand;
	}
	/**
	 * List<Brand> to List<BrandVO>
	 * @param brands
	 * @return
	 */
	public static List<BrandVO> toBrandVOs(List<Brand> brands){
		
		if (null==brands) {
			return Collections.emptyList();
		}
		List<BrandVO> brandVOs=new ArrayList<BrandVO>();
		for (Brand brand : brands) {
			brandVOs.add(BrandConverter.toBrandVO(brand));
		}
		return brandVOs;
	}
	

}
